﻿<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Pragma" content="no-cache">
<title></title>
<LINK href="../inc/editor.css" rel=stylesheet>
<style>
#inputwidth{width:30px;font-size:8pt;height:16px}
#inputheight{width:30px;font-size:8pt;height:16px}
#fieldset1{margin:5px}
#Amount{font-size:8pt;}

#message{color:#ffffff;position:relative;font-weight:bold;font-size:32pt;margin-top:100px}
#message1{position:relative;}

.blank{width:10px}
td{text-align:center}

.fieldsetsetting{
	width:150px
}
</style>
<script language="vbscript" src="../script/window.vbs"></script>
<script language="vbscript" src="../script/config.vbs"></script>

<script language="vbscript">
dim mmWidth,mmHeight,ImgSrcValue

Sub window_onload()
	ImgSrcValue=UnEscape(URLArgment("ImgSrc"))
	document.getElementByID("OrgImg").src=ImgSrcValue
	f1.ImgSrc.value=ImgSrcValue
	
	document.getElementByID("OrgImg").onload=getRef("OrgImgonload")
	
	f1.urlhref.value=location
End Sub

Sub btnPreview_onclick()
	dim myaction,it
	for each it in f1.myaction
		if it.checked then
			myaction=it.value
		end if
	next

	if myaction<>"" then
		'call doing("正在生成预览")
		With f1
			
			select case myaction
				case "resize":document.getElementByID("Preview").src="../"&Define_Server_ISAPI&"/render."&Define_Server_ISAPI&"?myaction=resize&ImgSrc="&ImgSrcValue&"&width="&.width.value&"&height="&.height.value
				case "sharp":document.getElementByID("Preview").src="../"&Define_Server_ISAPI&"/render."&Define_Server_ISAPI&"?myaction=sharp&ImgSrc="&ImgSrcValue&"&Amount="&.Amount.value
				case "crop":
					dim X0,Y0,X1,Y1
					dim Elem
					Set Elem=ViewFrm.document.getElementById("divCrop")
					if TypeName(Elem)="Nothing" then
						alert("请先设定裁剪范围")
					else
						X0=parseInt(Elem.style.left)
						Y0=parseInt(Elem.style.top)
						X1=X0+parseInt(Elem.style.width)
						Y1=Y0+parseInt(Elem.style.height)
						document.getElementByID("Preview").src="../"&Define_Server_ISAPI&"/render."&Define_Server_ISAPI&"?myaction=crop&ImgSrc="&ImgSrcValue&"&X0="&X0&"&Y0="&Y0&"&X1="&X1&"&Y1="&Y1
					end if
			end select
		End With
	else
		alert("请选择操作类型")
	end if
End Sub

Function parseInt(s)
	parseInt=Cint(Replace(s,"px",""))
End Function

sub Preview_onload()
	masker.style.display="none"
	document.getElementByID("info_Preview").innerText="尺寸： "&document.getElementByID("Preview").clientWidth&"×"&document.getElementByID("Preview").clientHeight
	document.getElementByID("info_Preview").scrollintoView
end sub

sub OrgImgonload()

	With document.getElementByID("OrgImg")
		mmWidth=.width
		mmHeight=.offsetHeight
	End With
	'if document.getElementByID("OrgImg").clientWidth>300 then
		document.getElementByID("info_OrgImg").innerText="原始尺寸： "&document.getElementByID("OrgImg").clientWidth&"×"&document.getElementByID("OrgImg").clientHeight
		With document.getElementByID("OrgImg")
			.style.display="none"
		End With
	'end if
	With ViewFrm.document
		.DesignMode="On"
		.Open

		.writeln "<html><body style=""background-image:url('"&document.getElementByID("OrgImg").src&"');margin:0""></body></html>"
		.Close
		.body.focus
		.execCommand "2D-Position",true,true				'IE5.5以上版本支持
		.execCommand "LiveResize",true,true
		.ondblclick=getRef("ReturnEventFalse")
		.onkeydown=getRef("ReturnEventFalse")
	End With
	With document.getElementById("ViewFrm")
		.style.height=mmHeight
		.style.width=mmWidth
	End With

end sub

Sub BtnCrop_onclick()
	set DivObj=ViewFrm.document.createElement("<div>")
	ViewFrm.document.body.appendChild(DivObj)
	DivObj.id="divCrop"
	DivObj.style.width=mmWidth
	DivObj.style.position="absolute"
	DivObj.style.border="1 solid #000000"
	DivObj.style.top=0
	DivObj.style.left=0
	DivObj.style.height=mmHeight
	DivObj.style.fontweight="bold"
	DivObj.style.textAlign="center"
	DivObj.style.verticalalign="middle"
	DivObj.style.backgroundcolor="#FFFFFF"
	DivObj.style.filter="alpha(opacity=80)"
	DivObj.ondblclick=getRef("ReturnEventFalse")
	DivObj.onresize=getRef("getII")
	f1.BtnCrop.disabled=True
End Sub

Function getII()
	set Elem=ViewFrm.document.parentwindow.event.srcElement
	Elem.innerText="Width:"&Elem.offsetWidth&"px , Height:"&Elem.offsetHeight&"px"
End Function

Function ReturnEventFalse()
	ViewFrm.document.parentwindow.event.returnValue=false
	ReturnEventFalse=false
End Function

sub doing(sText)
	masker.style.display=""
	masker.style.width=document.body.scrollWidth
	masker.style.Height=document.body.scrollHeight
	message.innerText=sText
end sub

Function BtnSavePic_onclick()
	dim myaction,it
	for each it in f1.myaction
		if it.checked then
			myaction=it.value
		end if
	next

	if myaction<>"" then
		select Case myaction
			Case "crop":

				dim X0,Y0,X1,Y1
				dim Elem
				Set Elem=ViewFrm.document.getElementById("divCrop")
				if TypeName(Elem)="Nothing" then
					alert("请先设定裁剪范围")
					Exit Function
				else
					X0=parseInt(Elem.style.left)
					Y0=parseInt(Elem.style.top)
					X1=X0+parseInt(Elem.style.width)
					Y1=Y0+parseInt(Elem.style.height)
					f1.action="../"&Define_Server_ISAPI&"/render."&Define_Server_ISAPI&"?X0="&X0&"&Y0="&Y0&"&X1="&X1&"&Y1="&Y1
				end if

			Case else
				f1.action="../"&Define_Server_ISAPI&"/render."&Define_Server_ISAPI&""
		End Select
		'call doing("正在保存图片")
		f1.submit()

	else
		alert("请选择操作类型")
	end if

End Function
</script>
</head>

<body style="margin:10px;position:absolute;z-index:0">
<form name="f1" action="" method="post" target="frm0">
<fieldset><legend>图片处理程式</legend>
	<table>
		<tr>
			<td>
				<fieldset class="fieldsetsetting"><legend><input name="myaction" value="resize" type="radio">改变尺寸</legend>
					宽<input type="text" name="width" id="inputwidth">px                                                                      
					<span class="blank"></span>
					高<input type="text" name="height" id="inputheight">px                                                                      
					<span class="blank"></span>
				</fieldset>
			</td>
			<td>
				<fieldset class="fieldsetsetting"><legend><input name="myaction" value="sharp" type="radio">锐化</legend>
					<select id="Amount" name="Amount">
						<option value="">锐化强度</option>
						<option value="150">150</option>
						<option value="200">200</option>
						<option value="250">250</option>
					</select>
				</fieldset>
			</td>
			<td>
				<fieldset class="fieldsetsetting"><legend><input name="myaction" value="crop" type="radio">裁减</legend>
					<input type="button" id="BtnCrop" value="裁减范围设置" class="XpButton51">
				</fieldset>
			</td>
		</tr>
	</table>

	<div>
		<input id="btnPreview" type="button" value="预览" class="XpButton51">
	</div>
	<table>
		<tr>
			<td>原图</td>
		</tr>
		<tr>
			<td>
				<iframe id="ViewFrm" src="../inc/null.htm" style="width:300px;height:300px" frameborder="no" scrolling="no"></iframe>
				<br>
				<a id="info_OrgImg"></a>
				<img id="OrgImg" alt="">
			</td>
		</tr>
		<tr>
			<td><hr></td>
		</tr>
		<tr>
			<td>预览</td>
		</tr>	
		<tr>
			<td>			
				<a id="info_Preview"></a>
				<br>
				<img id="Preview" src="" alt="">
				<br>
			</td>
		</tr>
		<tr>
			<td>                   
				<input type="button" id="BtnSavePic" value="保存图片" class="XpButton51">
			</td>
		</tr>
	</table>
</fieldset>

<input type="hidden" name="ImgSrc" value="">
<input type="hidden" name="urlhref">
<input type="hidden" name="cmd" value="done">
</form>
<iframe src="" name="frm0" style="display:none"></iframe>

<div id="masker" style="filter:alpha(opacity=80);background-color:#000000;position:absolute;display:none;top:0;left:0;width:100%;height:100%;text-align:center;vertical-align : bottom;">
	<div id="message"></div>
	<div id="message1">&lt;<img src="../images/loadingbar.gif" alt=""></div>
</div>
</body>

</html>
